import { getChannelsAPI } from '../../api/channel';
import { CHANNEL_SAVE_LIST, CHANNEL_UPDATE_ID } from './actionTypes';

export const getChannelsAction = (params) => {
  // action 中，
  // 返回 {type:'add'}是同步
  // 返回函数，是异步
  return async (dispatch) => {
    const res = await getChannelsAPI();
    // console.log('res -----> ', res);
    dispatch({ type: CHANNEL_SAVE_LIST, payload: res.data.channels });
  };
};

export const updateIdAction = (payload) => {
  return { type: CHANNEL_UPDATE_ID, payload };
};
